"""Update items"""

import os, sys, site

python_version = 'python%s.%s' % sys.version_info[:2]
site_path = os.path.abspath(
    os.path.normpath(
        os.path.join(os.path.dirname(__file__),
                     '../lib', python_version, 'site-packages')))

site.addsitedir(site_path)
sys.path.append(os.path.abspath(os.path.dirname(__file__)))

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

from django.db import connection
from mitems.tools.mail_processor import read_mailbox, directory_list

if __name__ == '__main__':
    for directory in directory_list():
        read_mailbox(directory)
    connection.close()